// 定时任务
const schedule = require('node-schedule');
const { Worker } = require('worker_threads');
const logger = require('./_logger');


module.exports = function () {
    function init() {
        const logWorker = new Worker('./utils/_logs_worker.js');
        // 开启 日志任务 每一小时触发一次
        schedule.scheduleJob('0 * * * *', () => {
            logWorker.postMessage({});
        });
        logWorker.on('error', (err) => {
            logger.errLog(`记录操作日志 执行错误：${err}`);
        });
    }
    setTimeout(() => {
        init();
    }, 1000 * 5)
}